# Huawei Technologies Co.,Ltd.

set(BITWISEOP_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bitwiseop.txt)
set(BITWISEOP_BIN ${CMAKE_CURRENT_BINARY_DIR}/bitwiseop.abc)
set(BITWISEOP_PA ${CMAKE_CURRENT_BINARY_DIR}/bitwiseop.pa)
set(BITWISEOP_JS ${CMAKE_CURRENT_SOURCE_DIR}/bitwiseop.js)
set(BITWISEOP_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${BITWISEOP_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${BITWISEOP_OUTPUT}
    COMMENT "running javascript bitwiseop testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${BITWISEOP_JS} --dump-assembly --output ${BITWISEOP_BIN} > ${BITWISEOP_PA}
    COMMAND rm -f ${BITWISEOP_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${BITWISEOP_OUTPUT}
    COMMAND bash ${BITWISEOP_VERIFY} ${BITWISEOP_OUTPUT}
)
add_custom_target(bitwiseop
    DEPENDS ${BITWISEOP_OUTPUT} ${BITWISEOP_VERIFY}
)
add_dependencies(bitwiseop es2panda ark)
add_dependencies(ecmascript_common_tests bitwiseop)
